\chapter*{Preface}

These are the lecture notes accompanying the course {\em Introduction to
Functional Programming}, which I taught at Cambridge University in the academic
year 1996/7.

This course has mainly been taught in previous years by Mike Gordon. I have
retained the basic structure of his course, with a blend of theory and
practice, and have borrowed heavily in what follows from his own lecture notes,
available in book form as Part II of \cite{gordon-plt}. I have also been
influenced by those who have taught related courses here, such as Andy Gordon
and Larry Paulson and, in the chapter on types, by Andy Pitts's course on the
subject.

The large chapter on examples is not directly examinable, though studying it 
should improve the reader's grasp of the early parts and give a better idea 
about how ML is actually used.

Most chapters include some exercises, either invented specially for this course
or taken from various sources. They are normally intended to require a little
thought, rather than just being routine drill. Those I consider fairly
difficult are marked with a (*).

These notes have not yet been tested extensively and no doubt contain various
errors and obscurities. I would be grateful for constructive criticism from any
readers.

\bigskip

John Harrison ({\tt jrh@cl.cam.ac.uk}).

% These are the lecture notes accompanying the course {\em
% Introduction to Functional Programming} which I taught at
% Cambridge University in the academic year 1996/7. The
% students were final year undergraduates or first year
% postgraduates taking a one-year course in computer science
% following studies in some other (usually scientific)
% subject. They were already familiar with imperative
% programming in Modula-3, and were taking a course in C
% concurrently with this one. This is emphatically intended to
% be a course in functional programming, not a course in
% programming using a functional language as the vehicle. That
% is, I lay stress on the unusual features of functional
% languages and try to show off ML in its natural application
% domains, while I do not cover many important topics that are
% not peculiar to functional programming, e.g. abstract types.
% In starred sections, some additional material is included.
% This was not intended for examination, and may be skipped
% without loss of understanding of the main part of the book.
% I hope, however, that some will find it interesting to
% pursue certain topics further, and that those people will
% find the starred parts a natural complement to the main
% text.
%
% There is no great shortage of books on functional
% programming, so perhaps a new one needs some justification
% for its existence. A distinctive feature of this course is
% that it spans the theoretical and practical sides of the
% subject, and covers this gamut in a steady progression. We
% start by discussing the lambda-calculus as a mathematical
% formalism and universal programming language. This is used
% as a foundation for appreciating the ML programming
% language, which (with the possible exception of LISP), is
% the most obviously `applied' and `practical' functional
% language --- indeed to purists, it is not a functional
% language at all. We discuss the imperative features of ML,
% give some hints for writing efficient programs, and give
% some realistic examples. The ML dialect used, CAML, has also
% now been used as the basis for a functional programming
% course published in English before.
%
% This course has mainly been taught in previous years by Mike
% Gordon. I have retained the basic structure of his course,
% with its above-mentioned blend of theory and practice, and
% have borrowed heavily in what follows from his own lecture
% notes, themselves available in book form as Part II of
% \cite{gordon-plt}. I have also been influenced by those who
% have taught related courses here, such as Andy Gordon and
% Larry Paulson and, in the chapter on types, by Andy Pitts's
% course on the subject.
